package AcWing;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Scanner;

/**
 * @author mu-chen
 * @create 2024-03-06 20:22
 * @description 93. 递归实现组合型枚举
 */

public class Main93{
    static final int N = 30;
    static int n, m;
    static int[] st = new int[N];// 0表示还没放数，1~n表示放了哪个数
    static BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException{
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt(); m = sc.nextInt();
        dfs(1, 1);
        out.flush(); out.close();
    }

    private static void dfs(int u, int start) throws IOException {
        if(u > m){
            for (int i = 1; i <= m; i++) System.out.print(st[i] + " ");
            System.out.println();
            return;
        }
        for (int i = start; i <= n; i++) {
            st[u] = i;
            dfs(u + 1, i + 1);
            st[u] = 0;
        }
    }
}
